﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AlimentadorGenerator
{
    /// <summary>
    /// Interaction logic for ValidateCtrl.xaml
    /// </summary>
    public partial class ValidateCtrl : UserControl
    {
        RegisterCode m_registerCode = new RegisterCode();

        public ValidateCtrl()
        {
            InitializeComponent();
        }

        public RegisterCode SetRegisterCode
        {
            set
            {
                m_registerCode = value;
                RequestTxtBox.Text = m_registerCode.GetRequestCode;
            }
        }

        private void CheckBtnClick(object sender, RoutedEventArgs e)
        {
            if (m_registerCode.ResponseCode(RequestTxtBox.Text))
            {
                if (ResponsetxtBox.Text == m_registerCode.GetResponseCode)
                {
                    ResponsetxtBox.Foreground = Brushes.DarkGreen;
                }
                else
                {
                    ResponsetxtBox.Foreground = Brushes.Red;
                }
            }
        }

        private void ResponsetxtBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
        {
            ResponsetxtBox.Text = ResponsetxtBox.Text.ToUpper();
        }

        private void RequestTxtBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
        {
            RequestTxtBox.Text = RequestTxtBox.Text.ToUpper();
        }
    }
}
